﻿
//双击事件
function CustomDbClick() {
    parent.closeWin(); //去掉双击功能   
}

//添加信息
var fnCustomAdd = function () {

}

//修改
var fnCustomEdit = function () {

}

//选择的是部门还是岗位
var selectEntity = "";

//适用部门
var fnSelectDept = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);

    selectEntity = "DEPT";

    document.getElementById("dialog1_h").innerHTML = "适用部门";
    document.getElementById("EditUIWindow").src = "../EditWidows/YUITree.aspx?r=" + Math.random() + "&entity=DatDepartment&masterPara=DatDepartment|DeptName|DeptID|ParentID|DeptPath|True";
    SetDWH(550, 480, YAHOO.example.container.dialog1);
    YAHOO.example.container.dialog1.show();
    getCheckedNodes();
}

//适用岗位
var fnSelectPost = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);

    selectEntity = "POSITION";

    document.getElementById("dialog1_h").innerHTML = "适用岗位";
    document.getElementById("EditUIWindow").src = "../EditWidows/YUITree.aspx?r=" + Math.random() + "&entity=DatPost&masterPara=DatPost|PostName|PostID|ParentID|DeptID|True&IsHighlightUpDown=false";
    SetDWH(550, 480, YAHOO.example.container.dialog1);
    YAHOO.example.container.dialog1.show();
    getCheckedNodes();
}

//调用YUITree.aspx的ChooseInfo方法，获取选中部门、岗位
var getChooseInfo = function () {
    //debugger;
    var editwindow = document.getElementById("EditUIWindow");
    if (editwindow && (selectEntity == "DEPT" || selectEntity == "POSITION")) {
        editwindow.contentWindow.ChooseInfo();
    }
}

//返回选中部门、岗位
var _fn = function (ids, names) {
    //debugger;
    if (ids == "" || ids == "undefined") return;
    //alert("ids:" + ids + "  names:" + names);
    //保存到数据库
    YAHOO.util.Connect.asyncRequest('POST', "../EHR/workTimeAjax.aspx?flag=saveNoWorkResult&ids=" + ids + "&nams=" + names + "&entity=" + selectEntity, {
        success: function (res) {
            try {
                var str = res.responseText;
                //debugger;
                if (str == "1") {
                    alert("保存成功！");
                    ReLoadData();
                }
                else {
                    alert("保存失败！");
                }
            }
            catch (e) { }
            finally { }
        },
        failure: function (error) {
            alert("数据错误：" + error.statusText);
        }
    }, null);
    YAHOO.example.container.dialog1.hide();
}

//员工选择
var fnSelectEmp = function () {
    selectEntity = "PERSON";
    document.getElementById("EditUIWindow").src = "../EHR/hrEmpNoWorkResult.aspx";
    SetDWH(800, 400, YAHOO.example.container.dialog1);
    YAHOO.example.container.dialog1.show();
}

//初始化
if (typeof ($) != "undefined") {
    $(document).ready(function () {
        //debugger;
        //if (selectEntity == "DEPT" || selectEntity == "POSITION") {
        var btn = $("#yui-gen7-button");
        btn.click(function () {
            getChooseInfo();
        });
        //}
    });
}



